#include <REGX52.H>
#include <Timer0.H>
#include <Delay.H>
#include <Nixie.H>
#include <Key.H>

sbit LED=P1^0;//因为用的是 J47连接的电机

unsigned char Counter,Compare;	
unsigned char KeyNum,Speed;

void main()
{
	Timer0_Init();
	while(1)
	{
		KeyNum = Key();
		if(KeyNum == 1)
		{
			Speed++;
			Speed%=4;
			if(Speed==0){Compare=0;}
			if(Speed==1){Compare=50;}
			if(Speed==2){Compare=75;}
			if(Speed==3){Compare=100;}

		}
		Nixie(1,Speed);
	}
}

void Timer0_Routine() interrupt 1
{
	TL0 = 0xA4;		//设置定时初值
	TH0 = 0xFF;		//设置定时初值
	Counter++;
	Counter%=100;//计数值变化范围限制在0~99
	if(Counter<Compare)
	{
		LED = 1;
	}
	else
	{
		LED = 0;
	}
}